FROM centos:centos7.9.2009 as builder
RUN  yum makecache
RUN yum install -y epel-release
RUN yum makecache && yum install -y golang

WORKDIR /go/release
RUN go env -w GOPROXY=https://goproxy.cn,direct

COPY ./go.mod ./go.mod
COPY ./go.sum ./go.sum
RUN go mod download
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
COPY . .
RUN go build




FROM centos:centos7.9.2009
WORKDIR /opt/server

COPY --from=builder /go/release/etc /opt/config
COPY --from=builder /go/release/discovery .

EXPOSE 8080
VOLUME [ "/opt/cert","/opt/config" ]
CMD ["/opt/server/discovery", "-f", "/opt/config/settings.yaml", "-p","8080"]

